import Vue from 'vue'
import Vuex from 'vuex'
import {getItem,setItem} from '../utils/storage.js'

Vue.use(Vuex)
const USER_KEY = 'user'

const moduleA = {
  state: {
    user: getItem(USER_KEY)
  },
  mutations: {
    setUser(state,data){
     state.user = data
     setItem(USER_KEY, state.user)
    }
  }
}
const moduleB = {
  state: {
    LOADING: false
  },
  mutations: {
    showLoading(state) {
      state.LOADING = true
    },
    hideLoading(state) {
      state.LOADING = false
    }
  }
}
export default new Vuex.Store({
  modules: {
    loading: moduleB,
    user: moduleA
  }
})

